package com.spring.serviceimp.product;

import java.util.List;
import java.util.Map;

import org.apache.commons.beanutils.BeanUtils;

import com.hibernate.dao.product.ProductMessageDao;
import com.hibernate.pojo.ProductMessage;
import com.spring.service.product.ProductMessageService;
import com.struts.form.ProductMessageForm;

public class ProductMessageServiceImp implements ProductMessageService
{
	private ProductMessageDao productMessageDao=null;
	private boolean bool=false;
	
	public Map findProductMessage(String hql,int page)
	{
		return productMessageDao.findProductMessage(hql, page);
	}
	public boolean saveProductMessage(ProductMessageForm productmessageform)
	{
		ProductMessage productmessage=new ProductMessage();
		try
		{
				BeanUtils.copyProperties(productmessage,productmessageform);
		}
		catch(Exception e)
		{
			bool=false;
			e.printStackTrace();
		}
		return productMessageDao.saveProductMessage(productmessage);
	}
	public boolean editProductMessage(ProductMessageForm productmessageform)
	{
		return productMessageDao.editProductMessage(productmessageform);
	}
	public boolean delProductMessage(Long id)
	{
		return productMessageDao.delProductMessage(id);
	}
	public boolean deleteBatchProductMessage(String ids)
	{
		return productMessageDao.deleteBatchProductMessage(ids);
	}
	public Map displayProductMessageInfo(Long id)
	{
		List list= productMessageDao.displayProductMessageInfo(id);
		//convert list to map
		Map map=(Map)list.get(0);
		return map;
	}
	
	
	
	public ProductMessageDao getProductMessageDao() {
		return productMessageDao;
	}
	public void setProductMessageDao(ProductMessageDao productMessageDao) {
		this.productMessageDao = productMessageDao;
	}
}
